package xyz.labmem.main.task

import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.scheduling.annotation.Scheduled
import xyz.labmem.base.core.consts.log

/**
 * 定时任务demo
 * @Author lty
 * @Date 2021/12/15 11:51
 */
@Configuration //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling // 2.开启定时任务
class TaskDemo {

    private val log = this.log()

    //3.添加定时任务
    @Scheduled(cron = "0 0 0 * * ?")
    private fun todo() {
        log.info("每晚12点开始执行定时任务！")
    }

}